﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Tree {

    private Room leaf = null;

    public Tree leftChild
    { get; set; }

    public Tree rightChild
    { get; set; }

    public Tree(Room room)
    {
        leaf = room;
        leftChild = null;
        rightChild = null;
    }

    public List<Room> GetLeaves()
    {
        if (this.leftChild == null && this.rightChild == null)
        {
            List<Room> tempList = new List<Room>();
            tempList.Add(leaf);
            return tempList;
        }
        else
        {
            List<Room> tempList1 = leftChild.GetLeaves();
            List<Room> tempList2 = rightChild.GetLeaves();
            tempList1.AddRange(tempList2);
            return tempList1;
        }
    }
}
